package com.efast.dmom.aps.datahandlers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.dmom.aps.bean.PlanOrderOperation;
import com.efast.dmom.aps.dao.PlanOrderOperationDao;
import com.efast.dmom.aps.entity.PlanOrderOperationEntity;
import com.efast.dmom.aps.util.TimeUtil;

@Component
public class PlanOrderOperationDataHandler {
	@Autowired
	private PlanOrderOperationDao  planOrderOperationDao;
	public void save(PlanOrderOperation obj) {
		obj.getInnerData().setSiteId(DataHandlerUtils.getSiteId());
		obj.getInnerData().setCreationTime(TimeUtil.getLocalDateTime());
		obj.getInnerData().setCreationTimeZone(TimeUtil.getLocalTimeZone());
		obj.getInnerData().setCreator(SpringWebUtils.getRequestUser());
		obj.getInnerData().setLastModifiedTime(TimeUtil.getLocalDateTime());
		obj.getInnerData().setLastModifiedTimeZone(TimeUtil.getLocalTimeZone());
		obj.getInnerData().setLastModifier(SpringWebUtils.getRequestUser());
//		obj.getInnerData().setCreationPid(dmomIdDao.getDmomPid());
//		obj.getInnerData().setLastModifiedPid(DataHandlerUtils.getDmomPid());
		obj.getInnerData().setRowStatus(1);
		obj.getInnerData().setRowTrxId(1);
		planOrderOperationDao.save(obj.getInnerData());
		
	}
	public void delete(PlanOrderOperation obj) {
		obj.getInnerData().setLastModifiedTime(TimeUtil.getLocalDateTime());
		obj.getInnerData().setLastModifiedTimeZone(TimeUtil.getLocalTimeZone());
		obj.getInnerData().setLastModifier(SpringWebUtils.getRequestUser());
//		obj.getInnerData().setLastModifiedPid(DataHandlerUtils.getDmomPid());
		obj.getInnerData().setRowTrxId(1);
		planOrderOperationDao.delete(obj.getInnerData());
	}
	public void update(PlanOrderOperation obj) {
		obj.getInnerData().setLastModifiedTime(TimeUtil.getLocalDateTime());
		obj.getInnerData().setLastModifiedTimeZone(TimeUtil.getLocalTimeZone());
		obj.getInnerData().setLastModifier(SpringWebUtils.getRequestUser());
//		obj.getInnerData().setLastModifiedPid(DataHandlerUtils.getDmomPid());
		obj.getInnerData().setRowTrxId(1);
		planOrderOperationDao.update(obj.getInnerData());
		
	}
	public PlanOrderOperation getById(long id) {
		PlanOrderOperationEntity byId = planOrderOperationDao.getById(id);
		PlanOrderOperation planOrderOperation = new PlanOrderOperation();
		planOrderOperation.setInnerData(byId);
		return planOrderOperation;
	}
	public PlanOrderOperation getByName(String name) {
		PlanOrderOperationEntity entity = planOrderOperationDao.getByName(name);
		PlanOrderOperation planOrderOperation = new PlanOrderOperation();
		planOrderOperation.setInnerData(entity);
		return planOrderOperation;
	}
	
	public PlanOrderOperation getByOrderNo(String orderNo) {
		PlanOrderOperationEntity entity = planOrderOperationDao.getByOrderNo(orderNo);
		PlanOrderOperation planOrderOperation = new PlanOrderOperation();
		planOrderOperation.setInnerData(entity);
		return planOrderOperation;
	}
	
}
